package com.ruoyi.web.service.knowledgebase.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.web.domain.knowledgebase.KnowledgeBase;
import com.ruoyi.web.mapper.knowledgebase.KnowledgeBaseMapper;
import com.ruoyi.web.service.knowledgebase.KnowledgeBaseService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: KnowledgeBaseServiceImpl
 * @author: z越
 * @date: 2024/2/20  9:54
 * @description
 */
@Service
public class KnowledgeBaseServiceImpl extends ServiceImpl<KnowledgeBaseMapper, KnowledgeBase>
        implements KnowledgeBaseService {

    @Override
    public KnowledgeBase findByName(String name) {
        if (StringUtils.isEmpty(name)) {
            return null;
        }
        return this.getOne(new LambdaQueryWrapper<KnowledgeBase>().eq(KnowledgeBase::getName,name));
    }

    @Override
    public List<KnowledgeBase> findAllByType(String type) {
        if (StringUtils.isEmpty(type)) {
            return new ArrayList<>();
        }
        return this.list(new LambdaQueryWrapper<KnowledgeBase>().eq(KnowledgeBase::getType,type));
    }
}
